import { createRouter, createWebHistory } from 'vue-router'
import HomePage from '@/pages/HomePage.vue'
import UserLoginPage from '@/pages/user/UserLoginPage.vue'
import UserRegisterPage from '@/pages/user/UserRegisterPage.vue'
import UserManagePage from '@/pages/admin/UserManagePage.vue'
import UserInfoPage from '@/pages/user/UserInfoPage.vue'
import PictureAddPage from '@/pages/picture/PictureAddPage.vue'
import PictureManagePage from '@/pages/admin/PictureManagePage.vue'
import PictureDetailPage from '@/pages/picture/PictureDetailPage.vue'
import PictureAddByBatchPage from '@/pages/picture/PictureAddByBatchPage.vue'
import SpaceManagePage from '@/pages/admin/SpaceManagePage.vue'
import SpaceAddPage from '@/pages/space/SpaceAddPage.vue'
import SpaceChekcPage from '@/pages/space/SpaceChekcPage.vue'
import SpaceDetailPage from '@/pages/space/SpaceDetailPage.vue'
import PictureSearchForm from '@/components/PictureSearchForm.vue'
import PictureSearchPage from '@/pages/picture/PictureSearchPage.vue'
import SpaceAnalyzePage from '@/pages/space/SpaceAnalyzePage.vue'
import SpaceUserManagePage from '@/pages/spaceuser/SpaceUserManagePage.vue'
import BarrageShowPage from '@/pages/barrage/BarrageShowPage.vue'
import BarrageManagePage from '@/pages/admin/BarrageManagePage.vue'
import BasicLayOut from '@/layout/BasicLayOut.vue'
import CommentManagePage from '@/pages/admin/CommentManagePage.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      component: BasicLayOut, // 基础布局组件
      children: [
        {
          path: '/',
          name: '主页',
          component: HomePage
        },
        {
          path: '/user/login',
          name: '用户登录',
          component: UserLoginPage
        },
        {
          path: '/user/register',
          name: '用户注册',
          component: UserRegisterPage
        },
        {
          path: '/user/info',
          name: '个人中心',
          component: UserInfoPage
        },
        {
          path: '/picture/:id',
          name: '图片详情',
          component: PictureDetailPage,
          props: true // 告诉 Vue 将 route.params 的值映射到该路由组件的 props 中
        },
        {
          path: '/picture/add',
          name: '创建图片',
          component: PictureAddPage
        },
        {
          path: '/picture/add/batch',
          name: '批量抓取图片',
          component: PictureAddByBatchPage
        },
        {
          path: '/picture/search',
          name: '以图搜图',
          component: PictureSearchPage
        },
        {
          path: '/space/add',
          name: '创建空间',
          component: SpaceAddPage
        },
        {
          path: '/space/check',
          name: '空间检查',
          component: SpaceChekcPage
        },
        {
          path: '/space/:id',
          name: '我的空间',
          component: SpaceDetailPage,
          props: true
        },
        {
          path: '/space/analyze',
          name: '空间分析',
          component: SpaceAnalyzePage
        },
        {
          path: '/spaceUserManage/:id',
          name: '成员管理',
          component: SpaceUserManagePage,
          props: true
        },
        {
          path: '/admin/userManage',
          name: '用户管理',
          component: UserManagePage
        },
        {
          path: '/admin/pictureManage',
          name: '图片管理',
          component: PictureManagePage
        },
        {
          path: '/admin/spaceManage',
          name: '空间管理',
          component: SpaceManagePage
        },
        {
          path: '/admin/barrageManage',
          name: '弹幕管理',
          component: BarrageManagePage
        },
        {
          path: '/admin/commentManage',
          name: '评论管理',
          component: CommentManagePage
        }
      ]
    },
    // 弹幕墙作为独立路由，不使用basicLayout
    {
      path: '/barrage/show',
      name: '弹幕墙',
      component: BarrageShowPage
    },
  ]
})

export default router
